﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;
/// <summary>
/// Summary description for _Bank
/// </summary>
public class _Bank
{
	public _Bank()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public int _id { get; set; }
    public string _bank_name { get; set; }
    public string _bank_swift { get; set; }

    static SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString);

    //Atlasa nepieciešamos datus priekš MyCompanies.aspx POPUP
    public static _Bank Select(string bank_id)
    {
        _Bank bank = new _Bank();
        SqlCommand SelCmd = new SqlCommand("SELECT * FROM BANK WHERE id=@bank_id", conn);
        SelCmd.Parameters.Add(new SqlParameter("@bank_id", System.Data.SqlDbType.Int)).Value = bank_id;
        conn.Open();
        SqlDataReader dr = SelCmd.ExecuteReader();
        while (dr.Read())
        {
            bank._id = (int) dr[0];
            bank._bank_name = dr[1].ToString();
            bank._bank_swift = dr[2].ToString();
        }
        dr.Close();
        conn.Close();
        return bank;
    }
}